package org.neptune.web.controller;

import java.util.List;

import org.neptune.api.entity.SeckillOrder;
import org.neptune.api.request.SeckillRequest;
import org.neptune.common.response.LayuiTableResponse;
import org.neptune.common.response.ResponseBean;
import org.neptune.service.service.SeckillOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lwl
 * @date 2020/4/1 16:27
 */
@RestController
@RequestMapping("/seckillOrder")
public class SeckillOrderController {

	@Autowired
	private SeckillOrderService seckillOrderService;

	@RequestMapping("/queryOrders")
	public LayuiTableResponse<SeckillOrder> queryOrders(SeckillRequest seckillRequest) {
		List<SeckillOrder> result = seckillOrderService.querySeckillOrders(seckillRequest);
		return LayuiTableResponse.success("success", result.size(), result);
	}

	@RequestMapping("/payOrder")
	public ResponseBean<Object> payOrder(SeckillRequest seckillRequest) {

		return seckillOrderService.payOrder(seckillRequest);
	}

	@RequestMapping("/cancelOrder")
	public ResponseBean<Object> cancelOrder(SeckillRequest seckillRequest) {

		return seckillOrderService.cancelOrder(seckillRequest);
	}
}
